package com.bootdo.project.controller;
import com.bootdo.project.domain.TNotice;
import com.bootdo.project.service.impl.TNoticeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.codegen.vo.Result;
import com.codegen.vo.Page;

import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 *
 * Created by xxxx on 2019/03/19.
 */
@Controller
@RequestMapping("/tNotice/")
public class TNoticeController {

    @Autowired
    TNoticeService tNoticeService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<TNotice>> selectAll(){
        return Result.success(tNoticeService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<TNotice> selectByPrimaryKey(Integer id){
        return Result.success(tNoticeService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<TNotice>> selectByCondition(TNotice record){
        return Result.success(tNoticeService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(TNotice record){
        return Result.success(tNoticeService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(TNotice record){
        return Result.success(tNoticeService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(TNotice record){
        return Result.success(tNoticeService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<TNotice>>> selectByPage(Page<TNotice> page){
        List<TNotice> list = null;
        page = page.sequentialDisplayCalculate(tNoticeService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = tNoticeService.selectByPage(page);
        }
        Page<List<TNotice>> result = new Page<List<TNotice>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition")
    @ResponseBody
    public Result<Integer> deleteByCondition(TNotice record){
        return Result.success(tNoticeService.deleteByCondition(record));
    }

    @RequestMapping("delete")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Integer id){
        return Result.success(tNoticeService.deleteByPrimaryKey(id));
    }

}
